package com.fruit.controller.app.index;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fruit.controller.base.BaseController;
import com.fruit.pojo.common.Page;
import com.fruit.pojo.index.PushPointConfig;
import com.fruit.service.index.IndexManager;
import com.fruit.util.ResultInfo;


/**
 * APP首页controller <br/>
 * @author shibeilei
 * @version 2017.11.30 12:20
 */
@Controller
@RequestMapping(value = "/app/")
public class IndexController extends BaseController {

	@Autowired
	private IndexManager indexService;

	/**
	 * APP首页推送锚点 <br/>
	 * @param appType app类型
	 * @param page 分页信息
	 * @return 返回信息
	 * @author shibeilei
     * @version 2017.11.30 11:40
	 */
	@RequestMapping(value = "/getPushUserAction", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Map<String, Object> getPushUserAction(String appType, Page page) {
		this.logBefore(logger, "APP首页推送锚点-开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			// 获取商品列表
			page.getParams().put("appType", appType);
			List<PushPointConfig> ppcList = indexService.getPushUserAction(page);

			resultMap.put("ppcList", ppcList);
			resultMap.put("result", this.initResult(ResultInfo.SUCCESS, "ok", ""));
		} catch (Exception e) {
			e.printStackTrace();
			this.logError(logger, e.getMessage());
			resultMap.put("result", this.initResult(ResultInfo.ERROR, "exception", "系统异常"));
		}
		this.logAfter(logger);
		return resultMap;
	}

}
